<?php
 /*********************************************************************************
*  República Bolivariana de Venezuela                     
*  Ministerio del Poder Popular de Ciencia y Tecnologia
*  Fundación Instituto de Ingenieria                                                                                                                              
*  Centro de Procesamiento Digital de Imagenes - (CPDI)                                    
*                                                                                 
*                                                                                                  
*  Creado por: Ing. Luis Diaz - ldiazj@fii.gob.ve    			                                                                      
*	                                                                              
***********************************************************************************/

//Fecha de Creación:  18/08/2010

class AppController extends Controller
{
	var $components = array('Acl', 'Auth', 'Session');

   /* function beforeFilter(){
    	$this->Session->delete('Usuario');		
		$this->set('logueo', $this->_estaLogueado());
    }*/
    
	
	function beforeFilter() {
		//Configure AuthComponent
		$this->Auth->userModel = 'Usuario';
		$this->Auth->fields = array(
			'username' => 'usuario',
			'password' => 'clave'
		);
		Security::setHash('md5');
		//$this->Auth->actionPath = "Controllers/";		
		$this->Auth->authorize = 'actions';
		$this->Auth->authError = "Lo siento, no tiene permisos para acceder a este proceso.";
		$this->Auth->loginAction = array('controller' => 'usuarios', 'action' => 'login');
		$this->Auth->logoutRedirect = array('controller' => '/');
		$this->Auth->loginRedirect = array('controller' => 'eventos', 'action' => 'index');
		
	}
	
	function _estaLogueado(){
		if($this->Session->check('Usuario.id')){
			$logueo = TRUE;
		}else{
			$logueo = FALSE;
		}
		
		return $logueo;
	}
	
	function _isLogged(){
		if(!$this->_estaLogueado()){
			$this->_throwLogin();die;
			//$this->redirect(array('action'=>'index'));
		}else{
			return TRUE;
		}
	}
	
	function _throwLogin(){
		echo '<script>
				jQuery(document).ready(function() {
					$.fancybox(
						{
							"title": "Inicio de Sesión",
							"href": "/duida/usuarios/login",
							"modal": true,
				        	"autoDimensions"	: false,
							"width"         		: "auto",
							"height"        		: "auto",
							"transitionIn"		: "none",
							"transitionOut"		: "none"
						}
					);
				});
			</script>';
	}
	
}
?>